cmake_minimum_required(VERSION 3.10)

project(TDLEE)
find_package(MPI REQUIRED)
if (MPI_FOUND)
    include_directories(${MPI_INCLUDE_PATH})
else (MPI_FOUND)
    message(SEND_ERROR "Can not find MPI libraries")
endif (MPI_FOUND)

set(EXE_NAME TDLEE)
set(CMAKE_C_COMPILER "/usr/bin/gcc")
set(CMAKE_CXX_COMPILER "/usr/bin/g++")
set (PROJECT_LINK_LIBS libmpi_cxx.so )
set(CGNS_PATH ./cgns-4.4.0/src)
#add_definitions(-D_MPI,-D_2D,-D_OPTDRP,-D_LNS)
add_definitions(-Wall -O2)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -save-temps=obj")
option(_MPI "MPI" ON)
message("_MPI " ${_MPI} )
option(_2D "2D" ON)
message("_2D " ${_2D} )
option(_LNS "LNS" OFF)
message("_LNS " ${_LNS} )
option(_OPTDRP "OPTDRP" ON)
message("_OPTDRP " ${_OPTDRP} )
option(_PMLSRC "PMLSRC" OFF)
message("_PMLSRC " ${_PMLSRC} )
option(_DEBUG "DEBUG" OFF)
message("_DEBUG " ${_DEBUG} )
option(_NDMESH "NDMESH" ON)
message("_NDMESH " ${_NDMESH} )
if (_MPI)
    add_definitions(-D_MPI)
endif()
if (_2D)
    add_definitions(-D_2D)
endif()
if (_LNS)
    add_definitions(-D_LNS)
endif()
if (_NDMESH)
    add_definitions(-D_NDMESH)
endif()
if (_EULER)
    add_definitions(-D_EULER)
endif()
if (_OPTDRP)
    add_definitions(-D_OPTDRP)
endif()
if (_PMLSRC)
    add_definitions(-D_PMLSRC)
endif()
if (_DEBUG)
    add_definitions(-D_DEBUG)
endif()

include_directories(SYSTEM include ${CGNS_PATH})
link_directories(${CGNS_PATH}/lib)
link_libraries(libcgns.so)

find_package(MPI REQUIRED)
if (MPI_FOUND) 
    include_directories(${MPI_INCLUDE_PATH}) 
else (MPI_FOUND) 
    message(SEND_ERROR "Can not find MPI libraries") 
endif (MPI_FOUND) 


file(GLOB SRCS "src/*.cpp")

add_executable(${EXE_NAME} ${SRCS})
target_link_libraries(${EXE_NAME} ${MPI_CXX_LIBRARIES})
